//
//  scorer.hpp
//  yuzon
//
//  Created by Alvin on 2023/3/29.
//

#pragma once

#include <opencv2/opencv.hpp>
#include "common.hpp"

class Scorer {
public:
  explicit Scorer(const std::string &angle_list_path);
  void Process(const KeypointResults &results,
               int frame,
               int &state,
               std::vector<std::vector<int>> &frame_scores);
  
private:
  int CalculateMaxScore(const std::vector<float> &user_angle,
                        const std::vector<std::vector<float>> &standard_angles);
  int CalculateScore(const std::vector<float> &user_angle,
                     const std::vector<float> &standard_angle);
  int CheckKeypoints(const std::vector<float> &keypoints);
  float GetAngle(const cv::Point2f &a, const cv::Point2f &b);
  std::vector<std::vector<float>> GetStandardAngles(int frame);
  std::vector<float> GetUserAngle(const std::vector<float> &keypoints);
  
  std::vector<float> start_angle_;
  std::vector<int> frame_offsets_;
  std::vector<std::vector<float>> angles_;
};
